var QRCode = require('../../utils/weapp-qrcode.js');
var qrcode;
Page({
	data: {
		memList: [],
		imageUrl: getApp().globalData.imageUrl
	},
	onShow: function() {
		this.getMember();
	},
	onLoad: function() {
		var winWidth;
		wx.getSystemInfo({
			success: function(res) {
				console.log(res.model)
				console.log(res.pixelRatio)
				console.log(res.windowWidth)
				console.log(res.windowHeight)
				console.log(res.language)
				console.log(res.version)
				console.log(res.platform)
				winWidth = res.windowWidth;
			}
		})

		var widthLeng = 220 * winWidth / 750;


		qrcode = new QRCode('canvas', {
			text: "https://go.24xiaomai.com/html5/xiaomaipu.html?recommendId=" + getApp().globalData.userInfo.memId,
			width: widthLeng,
			height: widthLeng,
			colorDark: "#ff4a48",
			colorLight: "#ffffff",
			correctLevel: QRCode.CorrectLevel.H,
		});
	},
	getMember: function() {
		var _self = this;
		wx.showLoading({
			title: '加载中',
			mask: true
		})
		wx.request({
			url: getApp().globalData.baseUrl + '/applet/fission/members.do',
			data: {
				memId: getApp().globalData.userInfo.memId
			},
			header: getApp().globalData.header,
			success: function(res) {
				wx.hideLoading()

				if (res.data.code == 200 && res.data.obj != null) {
					_self.setData({
						memList: res.data.obj
					})
				}

			}
		})
	},
	//分享
	onShareAppMessage: function(res) {
		console.log(res.target.dataset)
		var imgurl = this.data.imageUrl + '/group_sharev2.png'
		var shareStr = '送好友免费午餐';

		if (res.from === 'button') {
			// 来自页面内转发按钮
			wx.showShareMenu({
				withShareTicket: true
			})
		}
		return {
			title: shareStr,
			imageUrl: imgurl,
			//path: 'pages/investigationDetail/investigationDetail?code=' + this.data.code,
			path: "pages/loading/loading?memId=" + getApp().globalData.userInfo.memId,
			success: function(res) {
				// 转发成功
			},
			fail: function(res) {
				// 转发失败
			}
		}
	}
});